import os

balance = 0


def input_value_dispose(value):
    """
    输入值的处理, 对于不在 1 到 4 区间的数值, 函数返回 None
    :param value: 程序输入值
    :return: None
    """
    if value < 0 or 4 < value:
        print('输入值的不在指定范围!')
        return None

    return value


def show_account_balance():
    """
    展示账户余额
    :return: None
    """
    print(f'Blue, 你的账户余额为: {balance}.')


def deposit():
    """
    账户存款
    :return: None
    """

    global balance
    amount = int(input('请输入你的存储金额: '))
    if 0 < amount:
        balance += amount
        print(f'存储金额成功, 账户当前余额为: {balance}.')
    else:
        print('存储金额异常, 终止当前操作!')


def withdrawal():
    """
    账户取款
    :return: None
    """

    global balance
    amount = int(input('请输入你的取款金额: '))
    if 0 < amount:
        if amount <= balance:
            balance -= amount
            print(f'金额取款成功, 账户当前余额为: {balance}.')
        else:
            print('取款金额小于余额, 取款失败!')
    else:
        print('取款金额异常, 终止当前操作!')


def show_main_menu():
    """
    展示主菜单
    :return: None
    """
    print('----主菜单----')
    print('1. 查询余额')
    print('2. 存款')
    print('3. 取款')
    print('4. 退出程序')


while True:
    os.system('cls')
    show_main_menu()
    value = int(input('请输入你的选择: '))

    if input_value_dispose(value) is not None:
        if value == 1:
            show_account_balance()

        if value == 2:
            deposit()

        if value == 3:
            withdrawal()

        if value == 4:
            break
    input()
